<?php
	if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die ('Please do not load this page directly. Thanks!');
?>

<span id="comments"></span>
<div id="comments">
<?php
	if ( !empty($post->post_password) ) {
		if ( $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password ) {
		return;
		}
	}
?>

<?php
if ($comments) {
	$ping_count = $comment_count = 0;
	foreach ($comments as $comment){
		if(get_comment_type() == "comment"){ ?>
		<div class="index-comment">
			<div class="ic-avatar"><?php echo get_avatar(get_comment_author_email(), '37'); ?></div>
			<div class="ic-text">
				<div class="ic-meta"><?php echo get_comment_author_link(); ?> at <?php echo get_comment_date('H:i'); ?> on <?php echo get_comment_date('j F Y'); ?></div>
				<div><?php comment_text() ?></div>
			</div>
		</div>
<?php	} else { ?>
		<div class="index-comment">
			<div class="ic-text nofloat">
				<div class="ic-meta"><?php echo get_comment_author_link(); ?> at <?php echo get_comment_date('H:i'); ?> on <?php echo get_comment_date('j F Y'); ?></div>
				<div><?php comment_text() ?></div>
			</div>
		</div>
<?php 	}
	}
}
?>
	<span id="respond"></span>
	<div id="comment_form" class="index-comment">
	<?php if($post->comment_status != 'open') { ?>
		Comment form currently closed..
	<?php } else { ?>
		<form id="commentform" action="<?php bloginfo('wpurl') ?>/wp-comments-post.php" method="post">
		<?php if($user_ID) { ?>
			<div class="form_login">
				Logged in as <a href="<?php bloginfo('url') . 'wp-admin/profile.php'; ?>"><?php echo wp_specialchars( $user_identity, 1 ); ?></a>. <a href="<?php echo get_bloginfo('wpurl') . '/wp-login.php?action=logout&amp;redirect_to=' . get_permalink(); ?>">Logout</a>
			</div>
		<?php } else { ?>
			<div class="form_input">
				<input id="author" name="author" type="text" />
				<label for="author">Name</label>
			</div>
			<div class="form_input">
				<input id="email" name="email" type="text" />
				<label for="email">Email</label>
			</div>
			<div class="form_input">
				<input id="url" name="url" type="text" />
				<label for="url">Website</label>
			</div>
		<?php } ?>
			<div class="form_comment">
				<textarea name="comment"></textarea>
			</div>
			<div class="form_submit">
				<input type="submit" name="submit" value="Comment" class="submit" />
			</div>
			<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
		</form>
	<?php } ?>
	</div>
</div>